﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using System.Collections;

namespace CDTM.Modules.TraCuuDiem.Components
{
    public partial class QuyenDN
    {
        //---------------------------------------------------------------------------------------------

        public static int DeleteAll()
        {
            return DeleteDynamic("1=1");
        }

        //---------------------------------------------------------------------------------------------

        public static int DeleteDynamic(string whereCondition)
        {
            const string spName = "[dbo].[p_CDTM_QuyenDN_DeleteDynamic]";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@WhereCondition", SqlDbType.Text, whereCondition);

            return db.ExecuteNonQuery(dbCommand);
        }

        //---------------------------------------------------------------------------------------------

        public static int Update(string maSV, bool kichHoat)
        {
            const string spName = "[dbo].[p_CDTM_QuyenDN_Update_KichHoat]";
            SqlDatabase db = (SqlDatabase)DatabaseFactory.CreateDatabase();
            SqlCommand dbCommand = (SqlCommand)db.GetStoredProcCommand(spName);

            db.AddInParameter(dbCommand, "@MaSV", SqlDbType.VarChar, maSV);
            db.AddInParameter(dbCommand, "@DaKichHoat", SqlDbType.Bit, kichHoat);

            return db.ExecuteNonQuery(dbCommand);
        }
    }
}
